package com.yanqu.road.server.cmd.rank;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.config.BeautyMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = GameProtocol.S_GET_BEAUTY_RANK_DETAIL_INFO_FROM_CROSS, desc = "获取美女排行美女详细信息")
public class GetBeautyRankDetailInfoCmdFromCross implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {

        RankProto.GetBeautyRankDetailInfoCrossReqMsg msg = RankProto.GetBeautyRankDetailInfoCrossReqMsg.parseFrom(packet.getBytes());
        String userPatronsDetailInfoJsonStr = BeautyMgr.getUserBeautyDetailInfoJsonStr(msg.getReqMsg().getUserId(), msg.getReqMsg().getId());
        RankProto.GetBeautyRankDetailInfoRespMsg.Builder builder = RankProto.GetBeautyRankDetailInfoRespMsg.newBuilder();
        builder.setInfoJsonStr(userPatronsDetailInfoJsonStr);
        RankProto.GetBeautyRankDetailInfoCrossRespMsg.Builder respMsg = RankProto.GetBeautyRankDetailInfoCrossRespMsg.newBuilder();
        respMsg.setRespMsg(builder);
        respMsg.setFromServerId(msg.getFromServerId());
        respMsg.setFromUserId(msg.getFromUserId());
        YanQuMessage message = YanQuMessageUtils.buildMessage(Protocol.C_GET_BEAUTY_RANK_DETAIL_INFO_RETURN, respMsg);
        GamePlayerMgr.sendPacket(0, message);

    }
}
